class Solution {
    public int searchInsert(int[] nums, int target) {
        int pos = nums.length;
        int left = 0;
        int right = nums.length - 1;
        while(left <= right){
            int mid = left + ((right - left) >>> 1);
            if(target <= nums[mid]){
                pos = mid;
                right = mid - 1; 
            }else{
                left = mid + 1;
            }
        }
        return pos;
    }
}